<?php

namespace App\Domain\HealthHistory\Requests;

use Illuminate\Foundation\Http\FormRequest;

class OperationPost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'memberUid' => 'required|string',
            'hasOperation' => 'required_if:type,1|string|nullable',
            'values' => 'required_if:type,1|string|nullable',
            'names' => 'required_if:type,1|string|nullable',
            'type' => 'required|string',
        ];
    }

    public function messages()
    {
        return [
            'memberUid.required' => '用户ID必填',
            'hasOperation.required' => '是否有过手术史必填',
            'names.required' => '手术名称必填',
            'values.required' => '手术时间必填',
            'type.required' => '类型必填',
        ];
    }
}
